<div class="titlebar">
    <div class="fn-left"><a href="{:url('popupshop/sale/add')}" class="button button-blue"><i class="iconfont icon-add_icon"></i>增加</a></div>
    <div class="fn-right">
        <a href="{:url('popupshop/sale/index',['types'=>0])}" class="button {if $types == 0}button-green{/if}">全部商品</a>
        <a href="{:url('popupshop/sale/index',['types'=>1])}" class="button {if $types == 1}button-green{/if}">平台商品</a>
        <a href="{:url('popupshop/sale/index',['types'=>2])}" class="button {if $types == 2}button-green{/if}">用户商品</a>
        <a href="{:url('popupshop/sale/index',['types'=>3])}" class="button {if $types == 3}button-green{/if}">未成交</a>
        <a href="{:url('popupshop/sale/index',['types'=>4])}" class="button {if $types == 4}button-green{/if}">已成交</a>
    </div>
</div>
<div class="cards">
    <div class="card green">
        <div class="fn-left"><i class="iconfont icon-my_icon"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$platform}</div><div class="text">平台商品</div></div>
    </div>
    <div class="card green">
        <div class="fn-left"><i class="iconfont icon-my_icon"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$user}</div><div class="text">用户商品</div></div>
    </div>
    <div class="card yellow">
        <div class="fn-left"><i class="iconfont icon-renminbi1688"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$no_complete|money}</div><div class="text">未成交金额</div></div>
    </div>
    <div class="card yellow">
        <div class="fn-left"><i class="iconfont icon-renminbi1688"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$complete|money}</div><div class="text">已成交金额</div></div>
    </div>
</div>
{foreach $lists as $vo}
<table class="pure-table mb5">
    <thead>
        <tr>
            <th class="blue"><svg class="icon mr10 fn-f18" aria-hidden="true"><use xlink:href="#icon-cuxiaohuodong"></use></svg>{$vo.house.title}</th>
            <th class="w80 fn-tar">成本价</th>
            <th class="w80 fn-tar">委托价</th>
            <th class="w80 fn-tar">销售价</th>
            <th class="w80 fn-tac">状态</th>
        </tr>
    </thead>
    <tbody>
        <tr class="pure-table-title">
            <td colspan="5">
                <div class="fn-left mr10">创建时间：{$vo.create_time|date='Y-m-d H:i'}</div>
                <div class="fn-left">更新时间：{$vo.update_time|date='Y-m-d H:i'}</div>
                <div class="fn-right button-group">
                    {if $vo.is_pay}
                    <button class="button button-mini button-disabled"><i class="iconfont icon-edit"></i>编辑</button>
                    <button class="button button-mini button-disabled"><i class="iconfont icon-arrowdown"></i>下架</button>
                    <button class="button button-mini button-disabled"><i class="iconfont icon-arrowup"></i>上架</button>
                    <button class="button button-mini button-disabled"><i class="iconfont icon-lajixiang"></i>删除</button>
                    {else}
                    <a href="{:url('popupshop/sale/edit',['id' => $vo.id])}" class="button button-mini" msg="【下架】选择商品" issale="0"><i class="iconfont icon-edit"></i>编辑</a>
                    <button class="button button-mini bar" url="{:url('popupshop/sale/offSale',['id' => $vo.id])}" msg="【下架】选择商品" issale="0"><i class="iconfont icon-arrowdown"></i>下架</button>
                    <button class="button button-mini bar" url="{:url('popupshop/sale/onSale',['id' => $vo.id])}" msg="【上架】选择商品" issale="1"><i class="iconfont icon-arrowup"></i>上架</button>
                    <button class="button button-mini bar" url="{:url('popupshop/sale/delete',['id' => $vo.id])}" msg="【删除】选择商品? 可恢复" issale="2"><i class="iconfont icon-lajixiang"></i>删除</button>
                    {/if}
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="5" class="store">
                {if $vo.user_id == 0}
                    <div class="fn-left"><img src="__STATIC__/popupshop/me.png" class="w40"></div>
                    <div class="fn-left pl10">匿名<br /><spam class="badge bg-blue">官方小店</spam></div>
                {else}
                    <div class="fn-left"><img src="{$vo.user.face}" class="w40"></div>
                    <div class="fn-left pl10">{$vo.user.nickname}<br />{if $vo.store_id > 0}<spam class="badge bg-green">{$vo.store.name}</spam>{/if}</div>
                {/if}
            </td>
        </tr>
        <tr>
            <td>
                <table class="table">
                 <thead>
                    <tr>
                        <th class="w100 fn-tac">预览</th>
                        <th>产品信息</th>
                        <th class="w100 fn-tar">成本价</th>
                        <th class="w100 fn-tar">销售价</th>
                    </tr>
                 </thead>
                  <tbody>
                    <tr>
                        <td><img src="{$vo.house.img}?x-oss-process=style/80"  class="w80" /></td>
                        <td class="no"><spam class="badge bg-red mr5">主</spam>{$vo.house.name}<br ><span class="gray">{$vo.house.note}</span></td>
                        <td class="fn-tar">￥{$vo.house.cost_price}</td>
                        <td class="fn-tar">￥{$vo.house.sell_price}</td>
                    </tr>
                    {foreach $vo.gift as $rs}
                    <tr>
                        <td><img src="{$rs.img}?x-oss-process=style/80"  class="w80" /></td>
                        <td class="no"><spam class="badge bg-blue mr5">赠</spam>{$rs.name}<br ><span class="gray">{$rs.note}</span></td>
                        <td class="fn-tar">￥{$rs.cost_price}</td>
                        <td class="fn-tar">￥{$rs.sell_price}</td>
                    </tr>
                    {/foreach}
                </tbody>
                </table>
            </td>
            <td class="fn-tac">{$vo.user_cost_price}</td>
            <td class="fn-tac">{$vo.user_entrust_price}</td>
            <td class="fn-tac">{$vo.user_sale_price}</td>
            <td class="fn-tac">
                 {if $vo.is_out}
                    <span class="badge bg-blue">退出提货</span>
                {else}
                    {if $vo.is_sale}
                        {if $vo.is_pay}
                            <span class="badge">已成交</span>
                        {else}
                            <span class="badge bg-green">销售中</span>
                        {/if}
                    {else}
                        <span class="badge bg-red">下架中</span>
                    {/if}
                {/if}
            </td>
        </tr>
    </tbody>
</table>
{/foreach}
{$lists|raw}
<style type="text/css">
 .store{line-height:20px;}
</style>
<script type="text/javascript">
Do('base', 'layer',function () {
    $('.isDel').isDel();
    $(".bar").click(function () {
        var index = parent.layer.getFrameIndex(window.name);
        var url =  $(this).attr('url');
        parent.layer.confirm($(this).attr('msg'),{icon:3},function(index){
            $.post(url,function(data) {
                window.location.reload()
            },"json");
            parent.layer.close(index);
        });

    })
})
</script>